/**
 * 颜色类
 */
class color {
    static format (color, alpha = true) {
        if (!color) {
          return;
        }
        let r, g, b, a;
        if (color.indexOf("#") > -1) {
          let hex = color.slice(1); // 去掉'#'号
          r = parseInt("0x" + hex.slice(0, 2)) / 255;
          g = parseInt("0x" + hex.slice(2, 4)) / 255;
          b = parseInt("0x" + hex.slice(4, 6)) / 255;
          a = 1.0;
          if (hex.slice(6, 8) != "") {
            a = parseInt("0x" + hex.slice(6, 8)) / 255;
          }
        } else if (typeof color === "number") {
            r = (color & 0x0000ff)/255;
            g = ((color & 0x00ff00) >> 8)/255;
            b = ((color & 0xff0000) >> 16)/255;
            a = 1.0;
        } else {
          if (color.length == 3) {
            r = color[0];
            g = color[1];
            b = color[2]
            a = 1.0;
          } else {
            r = color[0];
            g = color[1];
            b = color[2];
            a = color[3];
          }
        }
        if (alpha) {
          return new Float32Array([r, g, b, a]);
        } else {
          return new Float32Array([r, g, b]);
        }
      }
}
export const WebTextureFormat = {
  // Uncompressed formats
  'rgb8unorm': {
    canGenerateMipmaps: true,
  },
  'rgba8unorm': {
    canGenerateMipmaps: true,
  },
  'rgb8unorm-srgb': {
    canGenerateMipmaps: true,
  },
  'rgba8unorm-srgb': {
    canGenerateMipmaps: true,
  },
  'rgb565unorm': {
    canGenerateMipmaps: true,
  },
  'rgba4unorm': {
    canGenerateMipmaps: true,
  },
  'rgba5551unorm': {
    canGenerateMipmaps: true,
  },

  'bgra8unorm': { canGenerateMipmaps: true }, // No WebGL equivalent
  'bgra8unorm-srgb': { canGenerateMipmaps: true }, // No WebGL equivalent

  // Floating point textures
  'rg11b10ufloat': {
    canGenerateMipmaps: false,
  },

  // Compressed formats
  'bc1-rgb-unorm': {
    compressed: { blockBytes: 8, blockWidth: 4, blockHeight: 4 },
  },
  'bc2-rgba-unorm': {
    compressed: { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
  },
  'bc3-rgba-unorm': {
    compressed: { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
  },
  'bc7-rgba-unorm': {
    compressed: { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
  },
  'etc1-rgb-unorm': {
    compressed: { blockBytes: 8, blockWidth: 4, blockHeight: 4 },
  },
  'etc2-rgba8unorm': {
    compressed: { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
  },
  'astc-4x4-rgba-unorm': {
    compressed: { blockBytes: 16, blockWidth: 4, blockHeight: 4 },
  },
  'pvrtc1-4bpp-rgb-unorm': {
    compressed: { blockBytes: 8, blockWidth: 4, blockHeight: 4 },
  },
  'pvrtc1-4bpp-rgba-unorm': {
    compressed: { blockBytes: 8, blockWidth: 4, blockHeight: 4 },
  },
};
export { color }